mui.init();
//获取本地信息
var my_phone = localStorage.getItem("my_phone");
var user_id = localStorage.getItem("user_id");
var preDeposit, Grade, status; //公共变量
window.onload = function() {
	mui.plusReady(function() {
		var self = plus.webview.currentWebview();
		preDeposit = self.preDeposit;
		$("#advance_payment_num").text(preDeposit);
		userinfo()
	});
}
//充值
document.getElementById("imprest_recharge").addEventListener("tap", function() {
	if(status == 2) {
		mui.toast('账户已被限制，请联系平台。');
		return;
	}
	mui.openWindow({
		url: "imprest_recha_copy.html",
		id: "imprest_recha_copy",
		createNew: true
	});
});
//预付款 提现记录
document.getElementById("advance_payment_detail").addEventListener("tap", function() {
	mui.openWindow({
		url: "advance_payment_detail.html",
		id: "advance_payment_detail"
	});
});
//提现
document.getElementById("put_forward").addEventListener("tap", function() {
	mui.openWindow({
		url: "../my/cash_advance.html",
		id: "cash_advance"
	});
});

//调用userinfo接口判断是否是商家
function userinfo() {
	mui.ajax(user_url + '/api/userinfo', { //查询用户信息接口
		data: {
			"phone": my_phone,
			"sign": "string",
			"user_id": user_id
		},
		dataType: 'json', //服务器返回json格式数据
		type: 'post', //HTTP请求类型
		timeout: 10000, //超时时间设置为10秒；
		headers: {
			'Content-Type': 'application/json'
		},
		success: function(data) {
			if(data.code == 10000) {
				Grade = data.resp.level; //个人等级
				status = data.resp.status; //账户状态
			}
		},
		error: function(xhr, type, errorThrown) { //异常处理；
			console.log(type);
		}
	});
}